/*
 * Items.hpp
 *
 *  Created on: Aug 19, 2013
 *      Author: jason
 */

#ifndef ITEMS_HPP_
#define ITEMS_HPP_
#include <string>
#include <vector>
#include <SFML/Graphics.hpp>
#include "../luaManager.hpp"

namespace OForce {

// Target Types:
// Items that can be used have three types of interaction
// Ally type can be used on oneself or an ally and are usually beneficial effects
// Enemy type can be used on enemies and attack or debuff
// Self-type items will probably just include items which are really team-wide
// however, it might also be possible to have self-buffing items
enum TARGET_TYPE {ALLY, ENEMY, SELF};
enum USABLE {NOWHERE, ANYWHERE, EXPLORE, BATTLE};

class GenericItem {
public:
	GenericItem() : mId(-1), mTargetType(ALLY), mPrice(0) {}
	GenericItem(int id);
	void readObjectData(LuaScript script);
	int getItemID() {return mId;}
	int getPrice() {return mPrice;}
	std::string getName() {return mName;}
	void setName(std::string name) {mName = name;}
	void setIcon(std::string filename);
	void setIconPosition(float x, float y);
	luabind::object getBattleUse() {return battleUse;}
	luabind::object getWorldUse() {return worldUse;}
protected:
	int mId;
	int mPrice;
	std::string mName;
	sf::Sprite mIcon;
	std::string mIconFile;
	sf::Texture mIconTexture;
	LuaScript script;
	// Some items have a use outside of battle (mostly stat-boosters)
	luabind::object worldUse;
	// Some weapons and accessories can be used in battle
	luabind::object battleUse;
	TARGET_TYPE mTargetType;
	USABLE mUsable;
};

class Item : public GenericItem {
public:
	Item(int id);
	~Item();
	// TODO remove this because it should be in an item manager class
	void draw();
private:
//	void loadObject(LuaScript script);
}; // class Object

class UsableItem : public Item{
public:
	bool isUsable() {return mUsable;}
private:
	bool mUsable;
//	LuaScript *useFunction;
};

class Equipment : public Item {
public:
	enum EquipmentType {WEAPON, ACCESSORY};
	int getAttack() {return mAttack;}
	int getDefense() {return mDefense;}
	int getAgility() {return mAgility;}
	int getEffect() {return mEffect;}
	bool isCursed() {return mCursed;}
	EquipmentType getType();
	void setType(EquipmentType e);
	void setUsableBy(std::vector<int> whichClasses);
	std::vector<int> getUsableBy() {return mUsableClasses;}
	int getUsableGender() {return mUsableGender;}
private:
	int mAttack;
	int mDefense;
	int mAgility;
	// Can a weapon have multiple effects? Sure: this should be some kind of mask
	int mEffect;
	bool mCursed;
	EquipmentType mType;
	// usableGender: 0 no restriction, 1 female only, 2 male only
	std::vector<int> mUsableClasses;
	int mUsableGender;
};
}


#endif /* ITEMS_HPP_ */
